package cn.edu.neusoft.practice.Controller;
//cn.edu.neusoft.practice
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu.neusoft.practice.mapper.RoomMapper;
import cn.edu.neusoft.practice.po.Room;

@CrossOrigin
@Controller
public class RoomController {

	//
	@Autowired
	private RoomMapper RoomMapper;
	
	@RequestMapping("/getAllRooms")
	@ResponseBody
	public List<Room> getAllRooms(){
		//return RoomMapper.selectList(null); //针对单表的查询方法
		return RoomMapper.getDepartsWithParentName();
	}
	
	@RequestMapping("/updateRoom")//更新科室
	   @ResponseBody
	    public int updateRoom(Room r){
	      return RoomMapper.updateById(r);

	    }
	    @RequestMapping("/addRoom")//加
	    @ResponseBody
	    public int addRoom(Room r){
	      return RoomMapper.insert(r);
	    }

	    @RequestMapping("/deleteRoom")//删
	    @ResponseBody
	    public int deleRoom(int roomId){
	      return RoomMapper.deleteById(roomId);
	    }

}